package cn.com.sparkle.paxos.net.factory;

import java.io.IOException;

import cn.com.sparkle.paxos.net.factory.netty.NettyClient;
import cn.com.sparkle.paxos.net.factory.netty.NettyServer;
import cn.com.sparkle.paxos.net.factory.raptor.RaptorClient;
import cn.com.sparkle.paxos.net.factory.raptor.RaptorServer;

public class NetFactory {
	
	public static NetClient makeClient(String type) throws IOException{
		if(type.equals("raptor")){
			RaptorClient raptorClient = new RaptorClient();
			return raptorClient;
		}else{
			return new NettyClient();
		}
	}
	public static NetServer makeServer(String type) throws IOException{
		if(type == null){
			throw new RuntimeException("unspported net layer :" + type);
		}
		if("raptor".equals(type.toLowerCase())){
			RaptorServer server = new RaptorServer();
			return server;
		}else if("netty".equals(type.toLowerCase())){
			return new NettyServer();
		}else{
			throw new RuntimeException("unspported net layer :" + type);
		}
	}
}
